﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;

namespace supermarket.method
{
    internal class Classsupnumberwarnset
    {
        SqlConnection con = new SqlConnection();
        SqlCommand cmd = new SqlCommand();
        SqlDataReader qlddr = null;  //数据缓冲区
        #region///礼品数量预警设置
        public void warnselect(string num, DataGridView dv)
        {
            try
            {
                string s;
                int i = 0;
                //1.连接数据库
                Classgetsql sqlcon = new Classgetsql();
                con = sqlcon.getcon();  //数据库已连接并打开    
                s = "select * from Table_gift where number <= '" + num + "'";   //无条件查询
                cmd = new SqlCommand(s, con);   //执行SQL语句
                qlddr = cmd.ExecuteReader();   //把sql语句执行结果读取到数据缓冲区qlddr中
                while (qlddr.Read())
                {
                    dv[0, i].Value = qlddr[0].ToString();  //mid
                    dv[1, i].Value = qlddr[1].ToString();  //mname
                    dv[2, i].Value = qlddr[2].ToString();  //mcode
                    dv[3, i].Value = qlddr[3].ToString();  //
                    i++;
                }
                qlddr.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }

        #endregion
    }
}
